import java.util.HashMap;
import java.util.List;


public class ForLoopFun extends Fun {

	public String varname;
	
	public ForLoopFun(HashMap<String, Expr> syms, String varname) {
		super(syms);
		this.varname = varname;
	}
	
	public Expr run(List args) {
		Expr startExpr = (Expr)args.get(0);
		Expr endExpr = (Expr)args.get(1);
		Expr runExpr = (Expr)args.get(2);
		
		int start = startExpr.run();
		int end = endExpr.run();
		System.out.println("kens_debug: " + start + ", " + end);
		int val = -1;
		for(int i=start; i < end; i++) {
			syms.put(varname, new NumExpr(syms, i));
			val = runExpr.run();
		}
		System.out.println("kens_debug: all done with repeat");
		return new NumExpr(syms, val);
	}

}
